using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using CE.User;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string _strMaintenance = CE.Configuration.MyConfigurationManager.GetAppSettingValue("IsMaintenance");
        if (_strMaintenance == "1")
        {
            Response.Redirect("~/maintenance.aspx");
        }
        if (!Page.IsPostBack)
        {

            DateTime _dtFBDOB = DateTime.MinValue;
            LogUserViewedHistory("Security page first time loaded.");
        }
    }

    protected void btnSignIn_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("AdminID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("AdminPass"))
                {
                    Session[CE.Global.General.Guest] = "Admin";
                    LogUserViewedHistory("Security page [admin=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Home.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [user=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("UserID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("UserPass"))
                {
                    Session[CE.Global.General.Guest] = "User";
                    LogUserViewedHistory("Security page [user=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Home.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [user=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("LibertyID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("LibertyPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("EtiqaID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("EtiqaPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ChartisID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ChartisPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            //May Bank
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("MayBankID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("MayBankPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            //CIMB
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("CIMBID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("CIMBPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            //Standard Chartered 
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("STDCID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("STDCPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            //RHB Bank
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("RHBID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("RHBPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("RSAID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("RSAPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ChinaID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ChinaPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("EQID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("EQPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ACEID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("ACEPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("1CoverID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("1CoverPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else if (TextBox1.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("DAID"))
            {
                if (TextBox2.Text == CE.Configuration.MyConfigurationManager.GetAppSettingValue("DAPass"))
                {
                    Session[CE.Global.General.Guest] = "Provider";
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login passed.");
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else
                {
                    LogUserViewedHistory("Security page [provider=" + TextBox1.Text + ";password=" + TextBox2.Text + "] login failed.");
                }
            }
            else
            {
                LogUserViewedHistory("Security page [userid=" + TextBox1.Text + ";password=" + TextBox2.Text + "] invalid login.");
            }
        }
        else
        {
            LogUserViewedHistory("Security page [userid=" + TextBox1.Text + ";password=" + TextBox2.Text + "] invalid login.");
        }
        
    }

    private void LogUserViewedHistory(string Description)
    {
        UserViewHistoryDB _userviewdb = new UserViewHistoryDB();
        _userviewdb.LogViewedHistory("CX", Request, Description);
    }
}